import 'package:lx_widgets_library/extension/enum_ex.dart';

// 车辆面板样式
enum VehiclePanelType {
  // 骑行时长
  rideDuration(0, "RideDuration"),

  // 最高速度
  maxSpeed(1, "MaxSpeed"),

  // 本次里程
  currentMileage(2, "CurrentMileage"),
  
  // 总里程
  totalMileage(3, "TotalMileage");

  final int rawValue;
  final String name;
  const VehiclePanelType(this.rawValue, this.name);
  // 通过 title 获取枚举类型
  static VehiclePanelType? getTypeByTitle(String title) =>
      VehiclePanelType.values
          .firstWhereOrNull((activity) => activity.name == title);
  // 通过 rawValue 获取枚举类型
  static VehiclePanelType? getTypeByNum(int rawValue) => VehiclePanelType.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue);
  // 通过 rawValue 获取 title
  static String? getValue(int rawValue) => VehiclePanelType.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue)
      ?.name;
}
